package com.zbj.zuul;

import org.jboss.logging.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * ZuulApplication
 *
 * @author weigang
 * @create 2019-08-13
 **/
@EnableZuulProxy
@SpringBootApplication
public class ZuulApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ZuulApplication.class, args);
        TokenFilter tokenFilter = applicationContext.getBean(TokenFilter.class);
        System.out.println(tokenFilter);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public TokenFilter tokenFilter() {
        return new TokenFilter();
    }

    // 针对zuul无效(feign有效)
    //@Bean
    //public Logger.Level loggerLevel() {
    //    return Logger.Level.DEBUG;
    //}
}